{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "Collapsed": "false",
    "kernel": "SoS"
   },
   "source": [
    "# Text SOS-kernel with Jupytext\n",
    "\n",
    "## What is SOS kernel\n",
    "\n",
    "SoS consists of a ployglot notebook that allows the use of multiple kernels in one Jupyter notebook, and a workflow system that is designed for daily computational research. Basically,\n",
    "\n",
    "- SoS Polyglot Notebook is a Jupyter Notebook with a SoS kernel.\n",
    "- SoS Notebook serves as a super kernel to all other Jupyter kernels and allows the use of multiple kernels in one Jupyter notebook.\n",
    "- SoS Workflow System is a Python based workflow system that is designed to be readable, shareable, and suitable for daily data analysis.\n",
    "- SoS Workflow System can be used from command line or use SoS Notebook as its IDE.\n",
    "\n",
    "![](https://vatlab.github.io/sos-docs/doc/media/SoS_Notebook_and_Workflow.png)\n",
    "\n",
    "### How to install SOS-kernel\n",
    "\n",
    "Please follow this [link](https://vatlab.github.io/sos-docs/running.html#Conda-installation) to setup SOS\n",
    "\n",
    "I run some issue with the latest version of R on my Mac, so I had to install an earlier version of R\n",
    "\n",
    "```\n",
    "conda install -c r r=3.5.1\n",
    "conda install sos-notebook jupyterlab-sos sos-papermill -c conda-forge\n",
    "```\n",
    "\n",
    "## Related issue with Jupytext\n",
    "\n",
    "Jupytext works fine with Python/R kernel but converts code cells into markdown cells when using the SOS kernel.\n",
    "\n",
    "cf the image below. It is a code cell. After saving the notebook and restart it, it converted the code cell into markdown\n",
    "\n",
    "<img width=\"734\" alt=\"Screenshot 2020-03-13 at 10 51 18\" src=\"https://user-images.githubusercontent.com/33351426/76610049-9e704600-6518-11ea-861e-b4f691d1a478.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "Collapsed": "false",
    "kernel": "SoS"
   },
   "source": [
    "## Step 1\n",
    "\n",
    "Please, choose SOS Kernel and then, in the cell code, choose SOS (or any other kernel available), the outcome is the same.\n",
    "\n",
    "![](https://drive.google.com/uc?export=view&id=1OtyxfwoRyVK23XHnmd9JR-crBgHBL5mt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "Collapsed": "false",
    "kernel": "SoS"
   },
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import numpy as np\n",
    "\n",
    "pd.DataFrame({\n",
    "    'x': np.random.random(10),\n",
    "    'y': np.random.random(10),\n",
    "})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "Collapsed": "false",
    "kernel": "python3"
   },
   "source": [
    "## Step 2\n",
    "\n",
    "Now, pair it with Jupytex\n",
    "\n",
    "![](https://drive.google.com/uc?export=view&id=1Wtx-YPAXY8HWHqzCcy4iIgHpzt_9emEn)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "Collapsed": "false",
    "kernel": "python3"
   },
   "source": [
    "### Step 3\n",
    "\n",
    "Save the notebook, restart and clear all, **save**, then Shut down kernel. Close the notebook and reopen"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "Collapsed": "false",
    "kernel": "python3"
   },
   "source": [
    "### Step 4\n",
    "\n",
    "Reopen the notebook. Here is the outcome\n",
    "\n",
    "![](https://drive.google.com/uc?export=view&id=12C70unbSPv0gHCZaCICEUy7kO7wM93JH)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SoS",
   "language": "sos",
   "name": "sos"
  },
  "language_info": {
   "codemirror_mode": "sos",
   "file_extension": ".sos",
   "mimetype": "text/x-sos",
   "name": "sos",
   "nbconvert_exporter": "sos_notebook.converter.SoS_Exporter",
   "pygments_lexer": "sos"
  },
  "sos": {
   "kernels": [
    [
     "python3",
     "python3",
     "python3",
     "",
     ""
    ]
   ],
   "version": "0.20.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}